<template>
  <div class="flex-app-continer">
    <vxe-modal
      show-zoom
      :zIndex='10'
      :showFooter='true'
      title='差额征税计算'
      ref='modal1'
      :resize="true"
      width='1000'
      height='250'>
      <div class='form-con'>
        <vxe-form  :data="searchFormData" ref='searchForm' @submit="submitSearch" :rules="collectDataRules" size="mini" title-align="right" title-width="300" style="width: 100%">
          <vxe-form-item title="含税金额：" field="taxAmount" :item-render="{}" >
            <template v-slot>
              <vxe-input  v-model="searchFormData.taxAmount" type="number" step="0.01" placeholder="请输入" class="my-search" ></vxe-input>
            </template>
          </vxe-form-item>
          <vxe-form-item title="扣除额：" field="minusAmount" :item-render="{}">
            <template v-slot>
              <vxe-input  v-model="searchFormData.minusAmount" type="number" step="0.01" placeholder="请输入" class="my-search"></vxe-input>
            </template>
          </vxe-form-item>
        </vxe-form>
        <div class='info-tip'>说明：不含税金额=含税金额-（含税金额-扣除额）*税率或征收率/（1+税率或征收率）</div>
      </div>
      <template v-slot:footer>
        <vxe-button @click="closeSearch" status="info">取消</vxe-button>
        <vxe-button @click="submitSearch" status="primary">保存</vxe-button>
      </template>
    </vxe-modal>
  </div>
</template>
<script>
import { mixin } from '@/utils/mixin.js'
export default {
  name: 'searchFormComp',
  mixins: [mixin],
  data() {
    return {
      searchFormData: {
        taxAmount: '', //搜索输入框内容
        minusAmount: ''
      },
      collectDataRules: {
        taxAmount: [
          {required: true, message: '请输入'}
        ],
        minusAmount: [
          {required: true, message: '请输入'}
        ]
      }
    }
  },
  components: {
  },
  // mixins: [mixin],
  created() {
  },
  mounted() {

  },
  methods: {
    reset (){
      this.searchFormData = {
        taxAmount: '', //搜索输入框内容
        minusAmount: ''
      }
    },
    async submitSearch(){
      let errMap = null;
      errMap = await this.$refs.searchForm.validate()
      if (errMap) {
        return
      }
      let taxAmount = this.searchFormData.taxAmount
      let minusAmount = this.searchFormData.minusAmount
      let slv = this.slv;
      

      let amount = (taxAmount - (taxAmount-minusAmount)*slv/(1+slv)).toFixed(2);
      this.$emit('added',{newAmount:amount,kce:minusAmount,jshj:taxAmount});
      this.closeSearch()
    },
    closeSearch(){
      this.reset()
      this.$refs.modal1.close()
    },
    show(row) {
      //this.reset()
      let slv = row.slv
      this.slv = slv
      this.$refs.modal1.open()
    }
  },
}
</script>
<style lang="scss">
.info-tip{margin-top:20px;width: 100%;text-align: center}
.op-area{position: absolute;left: 0;top:0;}
.expand-wrapper {
  padding: 20px;
}
.form-con{width: 900px; margin:0 auto;}
.vxe-form--item-title{max-width: 500px;}
.radio-area{width: 210px; margin:0 auto;position: relative;left:10px;padding-bottom:5px;}
.radio-tit{margin-right:10px;}
.box-tit{margin-bottom:10px;}
.my-search.vxe-input {
  height: 34px;
  width: 300px;
}
</style>